// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
  const name = event.name
  const sort = event.sort
  const addPicResult = await db.collection("sort").add({
    data: {
      name: name,
      sortNum: sort,
      isShow:0
    }
  })
  // console.log("addPicResult==" + JSON.stringify(addPicResult))
  if (addPicResult.errMsg == "collection.add:ok") {
    return {
      code: 0
    }
  } else {
    return {
      code: -1,
      msg: addPicResult.errMsg
    }
  }
}